/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1598534980218_101';

  // add your middleware config here
  config.middleware = [];

  config.cors = {
    origin: '*',
    allowMethods: 'GET,HEAD,OPTIONS,PUT,POST,DELETE,PATCH',
  }; // 跨域请求

  config.security = {
    csrf: {
      enable: false,
    },
  }; // 关闭服务器的csrf

  config.view = {
    mapping: {
      '.nj': 'nunjucks',
    },
    // 遍历所有的.nj文件给 nunjucks处理
    defaultExtension: '.nj',
    // 设置渲染的模板文件后缀为.nj
    defaultViewEngine: 'nunjucks',
    // 设置默认渲染引擎
  };

  config.sequelize = {
    dialect: 'mysql',
    database: 'blogsever',
    host: '39.99.143.114',
    port: '3306',
    username: 'blogroot',
    password: 'lhc07210911',
    define: {
      underscored: false,
      freezeTableName: true,
    },
  };
  config.multipart = {
    mode: 'file',
  };

  config.sms = {
    client: {
      accessKeyId: 'LTAI4GFzGjeEH6Wn1s71Y9jA',
      secretAccessKey: 'YUfbzL7RniKXY2RtcBbOUoiv5kqXJE',
    },
  };

  // oss 服务
  config.oss = {
    client: {
      accessKeyId: 'LTAI4GFzGjeEH6Wn1s71Y9jA', // 阿里云账号AccessKey
      accessKeySecret: 'YUfbzL7RniKXY2RtcBbOUoiv5kqXJE',
      bucket: 'liuhc', // oss存储名
      endpoint: 'oss-cn-zhangjiakou.aliyuncs.com', // oss 访问地址
      timeout: '60s',
    },
  };

  config.redis = {
    client: {
      port: 6379, // Redis port
      host: '127.0.0.1', // Redis host
      password: '',
      db: 0,
    },
  };

  config.io = {
    init: {},
    namespace: {
      '/': {
        // connectionMiddleware是在client保持连接的时候调用的中间件
        connectionMiddleware: [ 'connection' ],
        // packetMiddleware是在server发送包给client之后调用的中间件
        packetMiddleware: [ 'packet' ],
      },
    },
    redis: {
      host: '127.0.0.1',
      port: 6379,
    },
  };

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  return {
    ...config,
    ...userConfig,
  };
};
